<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	request.setAttribute("path", request.getContextPath());
%>
<script type="text/javascript">
$(function(){
	validate();
});
function validate(){

	$("#name").change(function (){
		check.emptyCheck("name");
	});
	
	$("#repairMonth").change(function(){
		check.emptyCheck("repairMonth") && check.intNum("repairMonth");
	});

	$("#secondCat").change(function(){
		if(${isNew}){
			check.emptyCheck("secondCat");
		}
	});
	
}
function validateCat(){

	if(${isNew}){
		return check.emptyCheck("secondCat");
	}
	return true;
}
function save(){
	
	var uri = "${root}/mst/pro/update"
	if(check.emptyCheck("name") & (check.emptyCheck("repairMonth") && check.intNum("repairMonth")) & validateCat()){
		common.ajaxSubmit(uri,"productForm","保存产品失败","",'common.windowClose()');
	}
	
}
</script>
<jsp:include page="../../base/master_js.jsp"></jsp:include>
<form  id="productForm" class="form-horizontal" role="form">
	<jsp:include page="../../base/token.jsp" />
	<input type="hidden" name="id" id="id" value="${product.id}" />
	<table class="table table-hover">
		<tr>
			<th>机型:</th>
			<td><input type="text" class="input-xlarge" name="name" id="name" maxlength="50" value="${product.name }" ></td>
			<th>保修期限(月):</th>
			<td><input type="text" class="input-xlarge" name="repairMonth" id="repairMonth" maxlength="5" value="${product.repairMonth}"  ></td>
		</tr>
		<c:if test="${!isNew}">
		<tr>
			<th>产品线(旧):</th>
			<td><span class="input-xlarge uneditable-input"><c:out value="${product.firstCat.name}"></c:out></span></td>
			<th>品牌(旧):</th>
			<td><span class="input-xlarge uneditable-input"><c:out value="${product.secondCat.name}"></c:out></span></td>
		</tr>
		</c:if>
		<tr>
			<th>产品线:</th>
			<td>
				<select id="firstCat" name="firstCat" class="input-xlarge" onchange="firstCatChange(this,'secondCat')">
					<option value=""></option>
					<c:forEach var="item" items="${firstCats}">
						<option value="${item.id }"><c:out value="${item.name }"/></option>
					</c:forEach>
				</select>
			</td>
			<th>品牌:</th>
			<td>
				<select id="secondCat" name="secondCat" class="input-xlarge" >
					<option value=""></option>
				</select>
			</td>
		</tr>
		<tr>
			<th>描述:</th>
			<td colspan="3">
				<input type="text" class="input-xxlarge" maxlength="500" name="description" value="${product.description}" id="description"  >
			</td>
		</tr>
		<tr>
			<th>创建人:</th>
			<td><span class="input-xlarge uneditable-input"><c:out value="${product.createUser}"></c:out></span></td>
			<th>创建时间:</th>
			<td><span class="input-xlarge uneditable-input"><fmt:formatDate value="${product.createTime}" pattern="yyyy-MM-dd hh:mm"/></span></td>
		</tr>
		<tr>
			<th>更新人:</th>
			<td><span class="input-xlarge uneditable-input"><c:out value="${product.updateUser}"></c:out></span></td>
			<th>更新时间:</th>
			<td><span class="input-xlarge uneditable-input"><fmt:formatDate value="${product.updateTime }" pattern="yyyy-MM-dd hh:mm"/></span></td>
		</tr>
	</table>
	
	<div class="form-actions text-center">
	      <button type="button" class="btn btn-success" onclick="save()">保存</button>
	       <button type="button" class="btn btn-default" onclick="common.windowClose()">关闭</button>
	</div>
</form>
